home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / systems / mac / textures / graphics / rotate.sty < prev    next >
Text File  |  1994-07-08  |  2KB  |  57 lines

  1. %
  2. %   These macros allow you to rotate or flip a \TeX\ box.  Very useful for
  3. %   sideways tables or upsidedown answers.
  4. %
  5. %   To use, create a box containing the information you want to rotate.
  6. %   (An hbox or vbox will do.)  Now call \@rotr\boxnum to rotate the
  7. %   material and create a new box with the appropriate (flipped) dimensions.
  8. %   \@rotr rotates right, \@rotl rotates left, \@rotu turns upside down, and
  9. %   \@rotf flips.  These boxes may contain other rotated boxes.
  10. %
  11. %   Originally written by Tomas Rokicki, and distributed with dvips.
  12. %   Modified for Textures by Barry Smith, Blue Sky Research, 08Jul94
  13.  
  14. \newdimen\@rotdimen
  15. \newbox\@rotbox
  16.  
  17. \def\@rotstart#1{\special{postscript 0 0 transform}% get current point
  18.   \special{rawpostscript gsave itransform 2 copy translate
  19.    #1 neg exch neg exch translate}}% #1 can be any origin-fixing transformation
  20. \def\@rotfinish{\special{rawpostscript currentfont grestore setfont}}% gets back in synch
  21. %
  22. %   First, the rotation right. The reference point of the rotated box
  23. %   is the lower right corner of the original box.
  24. %
  25. \def\@rotr#1{\@rotdimen=\ht#1\advance\@rotdimen by\dp#1%
  26.    \hbox to\@rotdimen{\hskip\ht#1\vbox to\wd#1{\@rotstart{90 rotate}%
  27.    \box#1\vss}\hss}\@rotfinish}
  28. %
  29. %   Next, the rotation left. The reference point of the rotated box
  30. %   is the upper left corner of the original box.
  31. %
  32. \def\@rotl#1{\@rotdimen=\ht#1\advance\@rotdimen by\dp#1%
  33.    \hbox to\@rotdimen{\vbox to\wd#1{\vskip\wd#1\@rotstart{270 rotate}%
  34.    \box#1\vss}\hss}\@rotfinish}%
  35. %
  36. %   Upside down is simple. The reference point of the rotated box
  37. %   is the upper right corner of the original box. (The box's height
  38. %   should be the current font's xheight, \fontdimen5\font,
  39. %   if you want that xheight to be at the baseline after rotation.)
  40. %
  41. \def\@rotu#1{\@rotdimen=\ht#1\advance\@rotdimen by\dp#1%
  42.    \hbox to\wd#1{\hskip\wd#1\vbox to\@rotdimen{\vskip\@rotdimen
  43.    \@rotstart{-1 dup scale}\box#1\vss}\hss}\@rotfinish}%
  44. %
  45. %   And flipped end for end is pretty ysae too. We retain the baseline.
  46. %
  47. \def\@rotf#1{\hbox to\wd#1{\hskip\wd#1\@rotstart{-1 1 scale}%
  48.    \box#1\hss}\@rotfinish}%
  49. %
  50. %   Now the user interface for LaTeX:  \rotate[type]{text} where
  51. %   ``type'' is `l' for left, `r' for right, `u' for upside-down, or
  52. %   `f' for flip.  `l' is the default.
  53. %
  54. \def\rotate{\@ifnextchar[{\@rotate}{\@rotate[l]}}
  55. \def\@rotate[#1]#2{\setbox\@rotbox=\hbox{#2}\@nameuse{@rot#1}\@rotbox}
  56.  
  57.